Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[POS] Custom payment UI — Part 2 | Separating CardReaderPaymentController's events from MultiLiveEvent #12870

Merged
merged 4 commits into from
Nov 19, 2024

Conversation

samiuelson
Copy link
Contributor

@samiuelson samiuelson commented Nov 5, 2024

Separating CardReaderPaymentController's events from MultiLiveEvent

Closes: #12823

This is part 2 of 5 PRs refactoring the Payment flow:

  1. [POS] Custom payment UI — Part 1 | Separating payment collection management from Android Framework
  2. [POS] Custom payment UI — Part 2 | Separating CardReaderPaymentController's events from MultiLiveEvent
  3. [POS] Custom Payment UI – Part 3 | Emitting UI–agnostic payment states in CardReaderPaymentController
  4. [POS] Custom payment UI — Part 4 | Switch from viewStateData to paymentState
  5. [POS] Custom payment UI — Part 5 | Unit tests clean up

⚠️ Don't merge — the branch will be merged together with the above ones after additional testing of the whole refactor.

Description

This PR refactors the way CardReaderPaymentController emits events:

  1. CardReaderPaymentController emits now sealed class CardReaderPaymentEvent instances. This is safer to operate on a set of (sealed) classes bound to the parent class. Additionally, this removes the dependency on the MultiLiveEvent.Event and MultiLiveEvent in CardReaderPaymentController. These classes are not needed and desirable in Woo POS.
  2. The existing CardReaderPaymentViewModel subscribes to the controller's events observable, maps it, and exposes in the form of the old model (extending MultiLiveEvent.Event) emitted by LiveData—retrofitting the existing UI implementation.

Testing information

As a result of the refactoring done within this PR, the app should work without any change. It's crucial to test the IPP flow in the store management and POS modes against regression. It may be useful to base on the test plan (pdfdoF-5Jz-p2).

The tests that have been performed

I tested the payment collection flow in both POS and store management modes, using card-present payment and TTP; and verified that the IPP flow works and is not changed.
Configurations:

  1. CA — payment collection/refund with Stripe test card (WisePad)
  2. US — payment collection/refund with Stripe test card (TTP, M2)
  3. Stripe and Woo Payments plugins
  • I have considered if this change warrants release notes and have added them to RELEASE-NOTES.txt if necessary. Use the "[Internal]" label for non-user-facing changes.

Reviewer (or Author, in the case of optional code reviews):

Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement:

  • The PR is small and has a clear, single focus, or a valid explanation is provided in the description. If needed, please request to split it into smaller PRs.
  • Ensure Adequate Unit Test Coverage: The changes are reasonably covered by unit tests or an explanation is provided in the PR description.
  • Manual Testing: The author listed all the tests they ran, including smoke tests when needed (e.g., for refactorings). The reviewer confirmed that the PR works as expected on big (tablet) and small (phone) in case of UI changes, and no regressions are added.

@samiuelson samiuelson added the status: do not merge Dependent on another PR, ready for review but not ready for merge. label Nov 5, 2024
@dangermattic
Copy link
Collaborator

dangermattic commented Nov 5, 2024

1 Error
🚫 This PR is tagged with status: do not merge label(s).
1 Warning
⚠️ Class CardReaderPaymentEvent is missing tests, but unit-tests-exemption label was set to ignore this.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Nov 5, 2024

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commit9f7c8a2
Direct Downloadwoocommerce-wear-prototype-build-pr12870-9f7c8a2.apk

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Nov 5, 2024

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App Name WooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commit9f7c8a2
Direct Downloadwoocommerce-prototype-build-pr12870-9f7c8a2.apk

@samiuelson samiuelson changed the title Custom payment UI — separating CardReaderPaymentController's events from MultiLiveEvent [POS] Custom payment UI — Part 2. Separating CardReaderPaymentController's events from MultiLiveEvent Nov 7, 2024
@samiuelson samiuelson changed the title [POS] Custom payment UI — Part 2. Separating CardReaderPaymentController's events from MultiLiveEvent [POS] Custom payment UI — Part 2 | Separating CardReaderPaymentController's events from MultiLiveEvent Nov 7, 2024
@samiuelson samiuelson added the feature: point of sale POS project label Nov 7, 2024
@samiuelson samiuelson added this to the 21.2 milestone Nov 7, 2024
@samiuelson samiuelson marked this pull request as ready for review November 8, 2024 10:44
@kidinov kidinov self-assigned this Nov 11, 2024
Copy link
Contributor

@kidinov kidinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code changes look good. Tests well too.

I left one np in the test, please take a look!

Base automatically changed from custom-payment-ui-1 to feature/custom-payment-ui November 19, 2024 14:36
@samiuelson samiuelson merged commit 4c8e61c into feature/custom-payment-ui Nov 19, 2024
14 of 17 checks passed
@samiuelson samiuelson deleted the custom-payment-ui-2 branch November 19, 2024 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: point of sale POS project status: do not merge Dependent on another PR, ready for review but not ready for merge. unit-tests-exemption
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants